package com.aiyige.page.publish.selectcoursetype.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by zhuyakun on 2017/11/8.
 */

public class CourseTypeItem implements Parcelable {
    public static final int TYPE_ADD = 1;
    public static final int TYPE_NORMAL = 2;

    String title;
    String id;
    int type;
    boolean selected;

    public CourseTypeItem() {
    }

    private CourseTypeItem(Builder builder) {
        setTitle(builder.title);
        setId(builder.id);
        setType(builder.type);
        setSelected(builder.selected);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public static final class Builder {
        private String title;
        private String id;
        private int type;
        private boolean selected;

        private Builder() {
            title = "";
            id = "";
            type = TYPE_NORMAL;
            selected = false;
        }

        public Builder title(String val) {
            title = val;
            return this;
        }

        public Builder id(String val) {
            id = val;
            return this;
        }

        public Builder type(int val) {
            type = val;
            return this;
        }

        public Builder selected(boolean val) {
            selected = val;
            return this;
        }

        public CourseTypeItem build() {
            return new CourseTypeItem(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.title);
        dest.writeString(this.id);
        dest.writeInt(this.type);
        dest.writeByte(this.selected ? (byte) 1 : (byte) 0);
    }

    protected CourseTypeItem(Parcel in) {
        this.title = in.readString();
        this.id = in.readString();
        this.type = in.readInt();
        this.selected = in.readByte() != 0;
    }

    public static final Creator<CourseTypeItem> CREATOR = new Creator<CourseTypeItem>() {
        @Override
        public CourseTypeItem createFromParcel(Parcel source) {
            return new CourseTypeItem(source);
        }

        @Override
        public CourseTypeItem[] newArray(int size) {
            return new CourseTypeItem[size];
        }
    };
}
